# to attach leaflet dependencies we do an invisible map
# otherwise procedural leaflets wont render
# https://stackoverflow.com/questions/63534247/recommended-way-to-initialize-js-renderer-in-asis-r-markdown-chunk
leaflet::leaflet(width = 0, height = 0)

Overall Performance

sli_performance%>%
  select(-raw_comparison) %>%
  DT::datatable()

Absolute Performance Plots

for (i in 1:nrow(sli_performance)){
  
  cat(sprintf("\n\n## %s\n\n", sli_performance$method[[i]]))
  
  print(plot_sli_performance(sli_performance$raw_comparison[[i]], 
                             title = sprintf("%s: Absolute performance", sli_performance$method[[i]]), 
                             plot_type = "absolute"))
}

SLI unoptimized

SLI mean absolute error

SLI mean absolute percentage error

SLI mean squared error

Absolute Performance Maps

for (i in 1:nrow(sli_performance)){
  
  cat(sprintf("\n\n## %s\n\n", sli_performance$method[[i]]))
  
  map <- leaflet_sli_performance(sli_performance$raw_comparison[[i]], ons_shp, "diff_count")
  
  cat(as.character(htmltools::tagList(map)))
}

SLI unoptimized

SLI mean absolute error

SLI mean absolute percentage error

SLI mean squared error

Relative Performance Plots

for (i in 1:nrow(sli_performance)){
  
  cat(sprintf("\n\n## %s\n\n", sli_performance$method[[i]]))
  
  print(plot_sli_performance(sli_performance$raw_comparison[[i]], 
                             title = sprintf("%s: Relative performance", sli_performance$method[[i]]), 
                             plot_type = "proportional"))
  
  print("\n\n")
  
  print(sli_performance$raw_comparison[[i]]$diff_prop %>% 
          abs() %>% 
          hist(main = paste0("Histogram of mean abs. pct. error, ", sli_performance$method[[i]])))
  
  print("\n\n")
  
  print(sli_performance$raw_comparison[[i]]$diff_prop %>%
          abs() %>%
          summary())
}

SLI unoptimized

[1] “” $breaks [1] 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0

$counts [1] 83 11 5 4 2 0 1 1 0 1

$density [1] 7.68518519 1.01851852 0.46296296 0.37037037 0.18518519 0.00000000 [7] 0.09259259 0.09259259 0.00000000 0.09259259

$mids [1] 0.05 0.15 0.25 0.35 0.45 0.55 0.65 0.75 0.85 0.95

$xname [1] “.”

$equidist [1] TRUE

attr(,“class”) [1] “histogram” [1] “” Min. 1st Qu. Median Mean 3rd Qu. Max. 0.000000 0.002648 0.014955 0.083289 0.080902 1.000000

SLI mean absolute error

## Warning: Removed 1 rows containing missing values (geom_point).

[1] “” $breaks [1] 0.0 0.2 0.4 0.6 0.8 1.0 1.2

$counts [1] 105 0 1 0 1 1

$density [1] 4.8611111 0.0000000 0.0462963 0.0000000 0.0462963 0.0462963

$mids [1] 0.1 0.3 0.5 0.7 0.9 1.1

$xname [1] “.”

$equidist [1] TRUE

attr(,“class”) [1] “histogram” [1] “” Min. 1st Qu. Median Mean 3rd Qu. Max. 0.000000 0.002261 0.010341 0.041462 0.024376 1.171429

SLI mean absolute percentage error

[1] “” $breaks [1] 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0

$counts [1] 101 4 1 0 1 0 0 0 0 1

$density [1] 9.35185185 0.37037037 0.09259259 0.00000000 0.09259259 0.00000000 [7] 0.00000000 0.00000000 0.00000000 0.09259259

$mids [1] 0.05 0.15 0.25 0.35 0.45 0.55 0.65 0.75 0.85 0.95

$xname [1] “.”

$equidist [1] TRUE

attr(,“class”) [1] “histogram” [1] “” Min. 1st Qu. Median Mean 3rd Qu. Max. 0.000000 0.002312 0.010932 0.034512 0.025847 1.000000

SLI mean squared error

[1] “” $breaks [1] 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1

$counts [1] 101 4 0 0 1 0 0 0 1 0 1

$density [1] 9.35185185 0.37037037 0.00000000 0.00000000 0.09259259 0.00000000 [7] 0.00000000 0.00000000 0.09259259 0.00000000 0.09259259

$mids [1] 0.05 0.15 0.25 0.35 0.45 0.55 0.65 0.75 0.85 0.95 1.05

$xname [1] “.”

$equidist [1] TRUE

attr(,“class”) [1] “histogram” [1] “” Min. 1st Qu. Median Mean 3rd Qu. Max. 0.00000 0.00278 0.01222 0.04421 0.02568 1.05714

Relative Performance Maps

for (i in 1:nrow(sli_performance)){
  
  cat(sprintf("\n\n## %s\n\n", sli_performance$method[[i]]))
  
  map <- leaflet_sli_performance(sli_performance$raw_comparison[[i]], ons_shp, "diff_prop")
  
  cat(as.character(htmltools::tagList(map)))
}

SLI unoptimized

SLI mean absolute error

## Warning in pal(plot_var): Some values were outside the color scale and will be
## treated as NA

SLI mean absolute percentage error

SLI mean squared error

3
## [1] 3